<?php

use think\migration\Migrator;
use think\migration\db\Column;

class Wmsg extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('wmsg',array('engine'=>'INnoDB'));
        $table->addColumn('msg_type', 'string',array('limit' => 30,'comment'=>'消息类型'))
            ->addColumn('openid', 'string',array('limit' => 60,'comment'=>'用户openid'))
            ->addColumn('wechat_id', 'string',array('limit' => 30,'comment'=>'微信id'))
            ->addColumn('content', 'string',array('limit' => 500,'default'=>'','comment'=>'内容'))
            ->addColumn('media_id', 'string',array('limit' => 100,'default'=>'','comment'=>'媒体id'))
            ->addColumn('msg_id', 'string',array('limit' => 100,'default'=>'','comment'=>'消息id'))
            ->addColumn('event', 'string',array('limit' => 30,'default'=>'','comment'=>'事件'))
            ->addColumn('event_key', 'string',array('limit' => 100,'default'=>'','comment'=>'事件key'))
            ->addColumn('create_time', 'integer',array('limit' => 10,'comment'=>'消息创建时间'))
            ->addIndex(array('openid'))
            ->addIndex(array('wechat_id'))
            ->addIndex(array('create_time','wechat_id'))
            ->create();
    }
}
